<template>
  <div>
    <!--<auth-buttons></auth-buttons>-->
    <test-buttons></test-buttons>
  </div>
</template>

<script>
  import Axios from 'axios'
  export default {
    data() {
      return {
        user: {}
      }
    },
    methods: {
      clickMe() {
        var params = new URLSearchParams();
        params.append("userId", "user1")
        var _this = this;
        this.$http.post('/api',params).then(res=> {
          console.log(res);
          _this.user = res.data;

        }).catch(e=>{
          console.error(e);
        });
//        this.$http({
//          method: 'post',
//          url: '/api',
//          data: {a: 1, b: 2, c: 2},
//          // params: {a: 1, b: 2, c: 2}
//        });
      }
    },
    components: {
      "auth-buttons":   (resolve) => {
//          require(['/api/html'], resolve)

        var $http = Axios.create();

//        console.log(this.user)
//        resolve({template: '<div><input></div>'});
        var params = new URLSearchParams();
        params.append("userId", "user1")
        // params.append("favors",JSON.stringify(["睡觉", "看电视"]))
        // params.append("orders",JSON.stringify([{time: 1},{id: 0}]));
        params.append("orders[0][time]",1)
        params.append("orders[1][id]",0)
        params.append("tests[0]","看电视");
        params.append("tests[1]","睡觉");
        params.append("tests[2]","看电视");
        params.append("obj[id]",1)
        params.append("obj[name]",1)
        params.append("fromDate", "2018-05-02")
        $http.post('/api/cust/customer/html',params).then(res=> {
          resolve({template: res.data});
        }).catch(e=>{
          console.error(e);
        });

        //$.ajaxSettings.traditional= true
//         $.post('/api/cust/customer/html',{orders:[{time: 1},{id: 0}], userId: 'user2', tests:"睡觉, 看电视", obj:{id: 1, name: '姓名'}})
        // $.ajax({
        //   url: '/api/cust/customer/html',
        //   method: 'POST',
        //   data: {orders:[{time: 1},{id: 0}], userId: 'user2', tests:["睡觉","看电视"], obj:{id: 1, name: '姓名'}}
        // })

      },
     // "test-buttons": () => import("../opts/test")
      "test-buttons": () => ({

        component: import("../opts/test")

      })
    }
  }
</script>

<style type="text/css" rel="stylesheet" scoped>
  .row {
    margin-left: 0px !important;
  }
</style>
